package com.smartboot.plus.wapper;

import com.alibaba.fastjson2.JSONObject;
import com.smartboot.plus.ignite.cache.MqttMetricCache;
import com.smartboot.plus.support.BaseMqttEntityWrapper;
import com.smartboot.plus.vo.MqttJvmCpuVO;



public class JvmCpuNodeWrapper extends BaseMqttEntityWrapper<MqttMetricCache, MqttJvmCpuVO> {

	public static JvmCpuNodeWrapper build() {
		return new JvmCpuNodeWrapper();
	}


	@Override
	public MqttJvmCpuVO entityVO(MqttMetricCache entity) {
		if (entity == null) {
			return null;
		}

		MqttJvmCpuVO mqttJvmCpuVO = JSONObject.parseObject(entity.getJvmCpu(), MqttJvmCpuVO.class);
		if (mqttJvmCpuVO != null) {
			mqttJvmCpuVO.setVmVersion(mqttJvmCpuVO.getVmVersion());
			mqttJvmCpuVO.setThreadCount(mqttJvmCpuVO.getThreadCount());
			//内存使用率
			mqttJvmCpuVO.setHeapUsagePercentageDouble(mqttJvmCpuVO.getHeapUsagePercentageDouble());
			//内存大小
			mqttJvmCpuVO.setTotalMemoryLimit(mqttJvmCpuVO.getTotalMemoryLimit());
			//堆内存使用
			mqttJvmCpuVO.setHeapMemoryUsed(mqttJvmCpuVO.getHeapMemoryUsed());
			//非堆内存
			mqttJvmCpuVO.setNonHeapMemoryUsed(mqttJvmCpuVO.getNonHeapMemoryUsed());
			//物理内存
			mqttJvmCpuVO.setTotalPhysicalMemory(mqttJvmCpuVO.getTotalPhysicalMemory());
			//进程 CPU 使用率
			mqttJvmCpuVO.setProcessCpuLoadDouble(mqttJvmCpuVO.getProcessCpuLoadDouble());
			//CPU使用率
			mqttJvmCpuVO.setSystemCpuLoadDouble(mqttJvmCpuVO.getSystemCpuLoadDouble());
			//CPU 数量
			mqttJvmCpuVO.setCpuCount(mqttJvmCpuVO.getCpuCount());
			//cpu架构
			mqttJvmCpuVO.setCpuArchitecture(mqttJvmCpuVO.getCpuArchitecture());
		}

		return mqttJvmCpuVO;
	}
}
